import { useEffect, useState } from "react";

export default function App() {
  const [count, setCount] = useState(0);
  const [person, setPerson] = useState({ name: "yunmu" });

  useEffect(() => {
    // person 的变化不会触发 useEffect , 因为第二个数组参数中只监听了 count
    document.title = count;
    console.log("监听count值");
  }, [count]);

  return (
    <div>
      <span>
        {count} -- {person.name}
      </span>
      <button onClick={() => setCount(count + 1)}> + 1</button>
      <button onClick={() => setPerson({ name: "linduidui" })}>setPerson</button>
    </div>
  );
}
